<?php
/**
 * App端登录账号扫一扫，pc端自动登录。
 * Author: lyun
 * Date: 2019/2/18
 * Created by Panxsoft.
 */


namespace App\Http\Controllers\Api\V1\App\Customers;

use App\Http\Controllers\ApiController;
use App\Models\Customers\ScanEvent;
use App\Services\Utils\Guard;
use Illuminate\Http\Request;

class ScanQrCodeController extends ApiController
{
    /**
     * App端登录账号扫一扫，pc端自动登录。
     *
     * @param Request $request
     * @return array|\Illuminate\Http\Response
     */
    public function scanQrCode(Request $request)
    {
        $scan_qrcode_code = $request->scan_qrcode_code;

        if ($scan_qrcode_code) {
            $customer = Guard::customer();
            $customer->update(['code' => $scan_qrcode_code, 'date_updated' => (string)Now()]);
        }

        return $this->response(compact('scan_qrcode_code'));
    }
}
